<template>
  <div class="goods-item" @click="click">
    <van-card
      :price="price"
      tag
      :num="item.num"
      centered
      :desc="item.description"
      :title="item.name"
    >
      <div slot="thumb" class="goods-img" :style="{backgroundImage: 'url('+ item.smallPicture+')'}"></div>
      <div slot="footer">
        <slot name="btn"></slot>
      </div>
    </van-card>
  </div>
</template>

<script>
export default {
  name: 'goods',
  props: {
    item: Object
  },
  computed: {
    price() {
      if (this.item.price) {
        return this.item.numberOfProduct + ' x ' + this.item.instantPrice
      }
    }
  },
  methods: {
    click() {
      this.$emit('click', this.item)
    }
  }
}
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
@import '../style/mixin.styl'
  
.goods-item
  background: #ffffff
  position relative
  padding 5px 0
  &::after
    border-b()
  .goods-img
    width 90px
    height 90px
    background-size cover
    background-position: center center
  .van-card__title
    font-size 14px
    margin 4px 0
    rows(2)
  .van-card__content--centered
    justify-content: space-around
  .van-card
    background: #ffffff
  .van-card__desc
    font-size 13px
    max-height 30px
    line-height: 15px
    rows(2)
  .van-card__price
    font-size 15px
  .van-ellipsis
    white-space: normal
  // .van-card__tag
  //   top auto
  //   left auto
  //   right 0
  //   bottom 2px
  //   .van-tag--mark
  //     border-radius .8em 0 0 .8em

</style>
